package com.playball.lottery.frm.buyhall;

import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.text.Html;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;
import android.widget.TextView;

import com.playball.lottery.R;
import com.playball.lottery.base.BaseActivity;
import com.playball.lottery.customview.ChildDTO;
import com.playball.lottery.customview.MyDialog;
import com.playball.lottery.util.DefConstants;


public class JclqHhtz extends BaseActivity implements DefConstants {

	TextView tv_wkname;
	View v_sf;
	View v_rfsf;
	View v_dxf;
	View v_sfc;

	Button btn_sf_zs;
	Button btn_sf_zf;
	Button btn_rfsf_zs;
	Button btn_rfsf_zf;
	Button btn_dxf_df;
	Button btn_dxf_xf;
	Button btn_sfc_zs1;
	Button btn_sfc_zs2;
	Button btn_sfc_zs3;
	Button btn_sfc_zs4;
	Button btn_sfc_zs5;
	Button btn_sfc_zs6;
	Button btn_sfc_ks1;
	Button btn_sfc_ks2;
	Button btn_sfc_ks3;
	Button btn_sfc_ks4;
	Button btn_sfc_ks5;
	Button btn_sfc_ks6;
	Button btn_ok;
	Button btn_cancel;

	TextView tv_rf;
	TextView tv_base_score;

	static ChildDTO childDTO;

	int gInd = 0;
	int cInd = 0;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.buy_jclq_hhtz);
		Intent intent = getIntent();
		childDTO = (ChildDTO) intent.getSerializableExtra("info");
		String wkName = intent.getStringExtra("wk").substring(0, 2);
		gInd = intent.getIntExtra("gindex", 0);
		cInd = intent.getIntExtra("cindex", 0);

		v_sf = findViewById(R.id.hhtz_sf);
		v_rfsf = findViewById(R.id.hhtz_rfsf);
		v_dxf = findViewById(R.id.hhtz_dxf);
		v_sfc = findViewById(R.id.hhtz_sfc);
		tv_base_score = (TextView) findViewById(R.id.dxf_score);
		tv_rf = (TextView) findViewById(R.id.rfsfrf);
		tv_wkname = (TextView) findViewById(R.id.textView1);
		btn_sf_zf = (Button) findViewById(R.id.sf_zf);
		btn_sf_zs = (Button) findViewById(R.id.sf_zs);
		btn_rfsf_zf = (Button) findViewById(R.id.rfsf_zf);
		btn_rfsf_zs = (Button) findViewById(R.id.rfsfzs);
		btn_dxf_df = (Button) findViewById(R.id.dxf_df);
		btn_dxf_xf = (Button) findViewById(R.id.dxf_xf);
		btn_sfc_ks1 = (Button) findViewById(R.id.sfc_ks1);
		btn_sfc_ks2 = (Button) findViewById(R.id.sfc_ks2);
		btn_sfc_ks3 = (Button) findViewById(R.id.sfc_ks3);
		btn_sfc_ks4 = (Button) findViewById(R.id.sfc_ks4);
		btn_sfc_ks5 = (Button) findViewById(R.id.sfc_ks5);
		btn_sfc_ks6 = (Button) findViewById(R.id.sfc_ks6);
		btn_sfc_zs1 = (Button) findViewById(R.id.sfc_zs1);
		btn_sfc_zs2 = (Button) findViewById(R.id.sfc_zs2);
		btn_sfc_zs3 = (Button) findViewById(R.id.sfc_zs3);
		btn_sfc_zs4 = (Button) findViewById(R.id.sfc_zs4);
		btn_sfc_zs5 = (Button) findViewById(R.id.sfc_zs5);
		btn_sfc_zs6 = (Button) findViewById(R.id.sfc_zs6);
		btn_ok = (Button) findViewById(R.id.hhtz_jclq_ok);
		btn_cancel = (Button) findViewById(R.id.hhtz_jclq_cancel);

		String sf = childDTO.getsPspf();
		String rfsf = childDTO.getsPRqspf();
		String dxf = childDTO.getsPdxf();
		String sfc = childDTO.getsPsfc();
		tv_wkname.setText(wkName + (childDTO.mId).substring(6) + "  " + childDTO.vTeam + "VS" + childDTO.hTeam);
		if (TextUtils.isEmpty(sf)) {
			v_sf.setVisibility(View.GONE);
		} else if ((sf.split("\\|")).length >= 2) {
			btn_sf_zf.setText(Html.fromHtml("<b>主负</b>  <font size='10dip' color='#0163bf'>" + (sf.split("\\|"))[0]
					+ "</font>"));
			btn_sf_zf.setTag(sf.split("\\|")[0]);// sp值存入button的tag，记录投注选项的sp值，为下面计算奖金使用
			btn_sf_zs.setText(Html.fromHtml("<b>主胜</b>  <font size='10dip' color='#0163bf'>" + (sf.split("\\|"))[1]
					+ "</font>"));
			btn_sf_zs.setTag((sf.split("\\|"))[1]);
			// 如果sp为-，按钮不显示
			if ("-".equals((sf.split("\\|"))[0])) {
				btn_sf_zf.setVisibility(View.GONE);
			}
			if ("-".equals((sf.split("\\|"))[1])) {
				btn_sf_zs.setVisibility(View.GONE);
			}
			if ("-".equals((sf.split("\\|"))[0]) && ("-".equals((sf.split("\\|"))[1]))) {
				v_sf.setVisibility(View.GONE);
			}
		} else {
			v_sf.setVisibility(View.GONE);
		}

		if (TextUtils.isEmpty(rfsf)) {
			v_rfsf.setVisibility(View.GONE);
		} else if ((rfsf.split("\\|")).length >= 3) {
			tv_rf.setText((rfsf.split("\\|"))[0]);
			btn_rfsf_zf.setText(Html.fromHtml("<b>主负</b>  <font size='10dip' color='#0163bf'>" + (rfsf.split("\\|"))[1]
					+ "</font>"));
			btn_rfsf_zf.setTag((rfsf.split("\\|"))[1]);
			btn_rfsf_zs.setText(Html.fromHtml("<b>主胜</b>  <font size='10dip' color='#0163bf'>" + (rfsf.split("\\|"))[2]
					+ "</font>"));
			btn_rfsf_zs.setTag((rfsf.split("\\|"))[2]);
			// 如果sp为-，按钮不显示
			if ("-".equals((rfsf.split("\\|"))[1])) {
				btn_rfsf_zf.setVisibility(View.GONE);
			}
			if ("-".equals((rfsf.split("\\|"))[2])) {
				btn_rfsf_zs.setVisibility(View.GONE);
			}
			if ("-".equals((rfsf.split("\\|"))[1]) && ("-".equals((rfsf.split("\\|"))[2]))) {
				v_rfsf.setVisibility(View.GONE);
			}
		}

		if (TextUtils.isEmpty(dxf)) {
			v_dxf.setVisibility(View.GONE);
		} else if ((dxf.split("\\|")).length >= 3) {
			String eQ = "";
			eQ = (dxf.split("\\|"))[0];
			if (!eQ.equals("")) {
				if (eQ.startsWith("+") || eQ.startsWith("-")) {
					eQ = eQ.substring(1, eQ.length());
				}
			}
			tv_base_score.setText(eQ);
			// tv_base_score.setText((dxf.split("\\|"))[0]);
			btn_dxf_df.setText(Html.fromHtml("<b>大分</b>  <font size='10dip' color='#0163bf'>" + (dxf.split("\\|"))[1]
					+ "</font>"));
			btn_dxf_df.setTag((dxf.split("\\|"))[1]);
			;
			btn_dxf_xf.setText(Html.fromHtml("<b>小分</b>  <font size='10dip' color='#0163bf'>" + (dxf.split("\\|"))[2]
					+ "</font>"));
			btn_dxf_xf.setTag((dxf.split("\\|"))[2]);
			// 如果sp为-，按钮不显示
			if ("-".equals((dxf.split("\\|"))[1])) {
				btn_dxf_df.setVisibility(View.GONE);
			}
			if ("-".equals((dxf.split("\\|"))[2])) {
				btn_dxf_xf.setVisibility(View.GONE);
			}
			if ("-".equals((dxf.split("\\|"))[1]) && ("-".equals((dxf.split("\\|"))[2]))) {
				v_dxf.setVisibility(View.GONE);
			}
		}

		if (TextUtils.isEmpty(sfc)) {
			v_sfc.setVisibility(View.GONE);
		} else if ((sfc.split("\\|")).length >= 12) {
			String[] sfcargs = sfc.split("\\|");
			btn_sfc_ks1.setText(Html.fromHtml("<b>1-5</b><br><font size='10dip' color='#0163bf'>" + sfcargs[0]
					+ "</font>"));
			btn_sfc_ks1.setTag(sfcargs[0]);
			btn_sfc_ks2.setText(Html.fromHtml("<b>6-10</b><br><font size='10dip' color='#0163bf'>" + sfcargs[1]
					+ "</font>"));
			btn_sfc_ks2.setTag(sfcargs[1]);
			btn_sfc_ks3.setText(Html.fromHtml("<b>11-15</b><br><font size='10dip' color='#0163bf'>" + sfcargs[2]
					+ "</font>"));
			btn_sfc_ks3.setTag(sfcargs[2]);
			btn_sfc_ks4.setText(Html.fromHtml("<b>16-20</b><br><font size='10dip' color='#0163bf'>" + sfcargs[3]
					+ "</font>"));
			btn_sfc_ks4.setTag(sfcargs[3]);
			btn_sfc_ks5.setText(Html.fromHtml("<b>21-25</b><br><font size='10dip' color='#0163bf'>" + sfcargs[4]
					+ "</font>"));
			btn_sfc_ks5.setTag(sfcargs[4]);
			btn_sfc_ks6.setText(Html.fromHtml("<b>26+</b><br><font size='10dip' color='#0163bf'>" + sfcargs[5]
					+ "</font>"));
			btn_sfc_ks6.setTag(sfcargs[5]);
			btn_sfc_zs1.setText(Html.fromHtml("<b>1-5</b><br><font size='10dip' color='#0163bf'>" + sfcargs[6]
					+ "</font>"));
			btn_sfc_zs1.setTag(sfcargs[6]);
			btn_sfc_zs2.setText(Html.fromHtml("<b>6-10</b><br><font size='10dip' color='#0163bf'>" + sfcargs[7]
					+ "</font>"));
			btn_sfc_zs2.setTag(sfcargs[7]);
			btn_sfc_zs3.setText(Html.fromHtml("<b>11-15</b><br><font size='10dip' color='#0163bf'>" + sfcargs[8]
					+ "</font>"));
			btn_sfc_zs3.setTag(sfcargs[8]);
			btn_sfc_zs4.setText(Html.fromHtml("<b>16-20</b><br><font size='10dip' color='#0163bf'>" + sfcargs[9]
					+ "</font>"));
			btn_sfc_zs4.setTag(sfcargs[9]);
			btn_sfc_zs5.setText(Html.fromHtml("<b>21-25</b><br><font size='10dip' color='#0163bf'>" + sfcargs[10]
					+ "</font>"));
			btn_sfc_zs5.setTag(sfcargs[10]);
			btn_sfc_zs6.setText(Html.fromHtml("<b>26+</b><br><font size='10dip' color='#0163bf'>" + sfcargs[11]
					+ "</font>"));
			btn_sfc_zs6.setTag(sfcargs[11]);
			// 如果sp为-，按钮不显示
			if ("-".equals(sfcargs[0])) {
				btn_sfc_ks1.setVisibility(View.GONE);
			}
			if ("-".equals(sfcargs[1])) {
				btn_sfc_ks2.setVisibility(View.GONE);
			}
			if ("-".equals(sfcargs[2])) {
				btn_sfc_ks3.setVisibility(View.GONE);
			}
			if ("-".equals(sfcargs[3])) {
				btn_sfc_ks4.setVisibility(View.GONE);
			}
			if ("-".equals(sfcargs[4])) {
				btn_sfc_ks5.setVisibility(View.GONE);
			}
			if ("-".equals(sfcargs[5])) {
				btn_sfc_ks6.setVisibility(View.GONE);
			}
			// 主胜
			if ("-".equals(sfcargs[6])) {
				btn_sfc_zs1.setVisibility(View.GONE);
			}
			if ("-".equals(sfcargs[7])) {
				btn_sfc_zs2.setVisibility(View.GONE);
			}
			if ("-".equals(sfcargs[8])) {
				btn_sfc_zs3.setVisibility(View.GONE);
			}
			if ("-".equals(sfcargs[9])) {
				btn_sfc_zs4.setVisibility(View.GONE);
			}
			if ("-".equals(sfcargs[10])) {
				btn_sfc_zs5.setVisibility(View.GONE);
			}
			if ("-".equals(sfcargs[11])) {
				btn_sfc_zs6.setVisibility(View.GONE);
			}
			// sp全-，全隐藏
			if ("-".equals(sfcargs[0]) && ("-".equals(sfcargs[1])) && ("-".equals(sfcargs[2]))
					&& ("-".equals(sfcargs[3])) && ("-".equals(sfcargs[4])) && ("-".equals(sfcargs[5]))
					&& ("-".equals(sfcargs[6])) && ("-".equals(sfcargs[7])) && ("-".equals(sfcargs[8]))
					&& ("-".equals(sfcargs[9])) && ("-".equals(sfcargs[10])) && ("-".equals(sfcargs[11]))) {
				v_sfc.setVisibility(View.GONE);
			}
		}

		btn_sf_zf.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				if (btn_sf_zf.isSelected() == true) {
					btn_sf_zf.setSelected(false);
					// System.out.println("btn_sf_zf.setOnClickListener:d-"+childDTO.hhtz1);
					childDTO.hhtz1 = childDTO.hhtz1.replace("2", "");
					// System.out.println("btn_sf_zf.setOnClickListener:d-"+childDTO.hhtz1);
				} else {
					btn_sf_zf.setSelected(true);
					// System.out.println("btn_sf_zf.setOnClickListener:a-"+childDTO.hhtz1);
					childDTO.hhtz1 += "2";
					// System.out.println("btn_sf_zf.setOnClickListener:a-"+childDTO.hhtz1);
				}
			}
		});

		btn_sf_zs.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				if (btn_sf_zs.isSelected() == true) {
					btn_sf_zs.setSelected(false);
					childDTO.hhtz1 = childDTO.hhtz1.replace("1", "");
				} else {
					btn_sf_zs.setSelected(true);
					childDTO.hhtz1 += "1";
				}
			}
		});

		btn_rfsf_zf.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				if (btn_rfsf_zf.isSelected() == true) {
					btn_rfsf_zf.setSelected(false);
					childDTO.hhtz2 = childDTO.hhtz2.replace("2", "");
				} else {
					btn_rfsf_zf.setSelected(true);
					childDTO.hhtz2 += "2";
				}
			}
		});

		btn_rfsf_zs.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				if (btn_rfsf_zs.isSelected() == true) {
					btn_rfsf_zs.setSelected(false);
					childDTO.hhtz2 = childDTO.hhtz2.replace("1", "");
				} else {
					btn_rfsf_zs.setSelected(true);
					childDTO.hhtz2 += "1";
				}
			}
		});

		btn_dxf_df.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				if (btn_dxf_df.isSelected() == true) {
					btn_dxf_df.setSelected(false);
					childDTO.hhtz3 = childDTO.hhtz3.replace("1", "");
				} else {
					btn_dxf_df.setSelected(true);
					childDTO.hhtz3 += "1";
				}
			}
		});
		btn_dxf_xf.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				if (btn_dxf_xf.isSelected() == true) {
					btn_dxf_xf.setSelected(false);
					childDTO.hhtz3 = childDTO.hhtz3.replace("2", "");
				} else {
					btn_dxf_xf.setSelected(true);
					childDTO.hhtz3 += "2";
				}
			}
		});

		btn_sfc_ks1.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				if (btn_sfc_ks1.isSelected() == true) {
					btn_sfc_ks1.setSelected(false);
					childDTO.hhtz4 = childDTO.hhtz4.replace("1", "");
				} else {
					btn_sfc_ks1.setSelected(true);
					childDTO.hhtz4 += "1";
				}
			}
		});

		btn_sfc_ks2.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				if (btn_sfc_ks2.isSelected() == true) {
					btn_sfc_ks2.setSelected(false);
					childDTO.hhtz4 = childDTO.hhtz4.replace("2", "");
				} else {
					btn_sfc_ks2.setSelected(true);
					childDTO.hhtz4 += "2";
				}
			}
		});

		btn_sfc_ks3.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				if (btn_sfc_ks3.isSelected() == true) {
					btn_sfc_ks3.setSelected(false);
					childDTO.hhtz4 = childDTO.hhtz4.replace("3", "");
				} else {
					btn_sfc_ks3.setSelected(true);
					childDTO.hhtz4 += "3";
				}
			}
		});
		btn_sfc_ks4.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				if (btn_sfc_ks4.isSelected() == true) {
					btn_sfc_ks4.setSelected(false);
					childDTO.hhtz4 = childDTO.hhtz4.replace("4", "");
				} else {
					btn_sfc_ks4.setSelected(true);
					childDTO.hhtz4 += "4";
				}
			}
		});
		btn_sfc_ks5.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				if (btn_sfc_ks5.isSelected() == true) {
					btn_sfc_ks5.setSelected(false);
					childDTO.hhtz4 = childDTO.hhtz4.replace("5", "");
				} else {
					btn_sfc_ks5.setSelected(true);
					childDTO.hhtz4 += "5";
				}
			}
		});
		btn_sfc_ks6.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				if (btn_sfc_ks6.isSelected() == true) {
					btn_sfc_ks6.setSelected(false);
					childDTO.hhtz4 = childDTO.hhtz4.replace("6", "");
				} else {
					btn_sfc_ks6.setSelected(true);
					childDTO.hhtz4 += "6";
				}
			}
		});
		btn_sfc_zs1.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				if (btn_sfc_zs1.isSelected() == true) {
					btn_sfc_zs1.setSelected(false);
					childDTO.hhtz4 = childDTO.hhtz4.replace("a", "");
				} else {
					btn_sfc_zs1.setSelected(true);
					childDTO.hhtz4 += "a";
				}
			}
		});
		btn_sfc_zs2.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				if (btn_sfc_zs2.isSelected() == true) {
					btn_sfc_zs2.setSelected(false);
					childDTO.hhtz4 = childDTO.hhtz4.replace("b", "");
				} else {
					btn_sfc_zs2.setSelected(true);
					childDTO.hhtz4 += "b";
				}
			}
		});
		btn_sfc_zs3.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				if (btn_sfc_zs3.isSelected() == true) {
					btn_sfc_zs3.setSelected(false);
					childDTO.hhtz4 = childDTO.hhtz4.replace("c", "");
				} else {
					btn_sfc_zs3.setSelected(true);
					childDTO.hhtz4 += "c";
				}
			}
		});
		btn_sfc_zs4.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				if (btn_sfc_zs4.isSelected() == true) {
					btn_sfc_zs4.setSelected(false);
					childDTO.hhtz4 = childDTO.hhtz4.replace("d", "");
				} else {
					btn_sfc_zs4.setSelected(true);
					childDTO.hhtz4 += "d";
				}
			}
		});
		btn_sfc_zs5.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				if (btn_sfc_zs5.isSelected() == true) {
					btn_sfc_zs5.setSelected(false);
					childDTO.hhtz4 = childDTO.hhtz4.replace("e", "");
				} else {
					btn_sfc_zs5.setSelected(true);
					childDTO.hhtz4 += "e";
				}
			}
		});
		btn_sfc_zs6.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				if (btn_sfc_zs6.isSelected() == true) {
					btn_sfc_zs6.setSelected(false);
					childDTO.hhtz4 = childDTO.hhtz4.replace("f", "");
				} else {
					btn_sfc_zs6.setSelected(true);
					childDTO.hhtz4 += "f";
				}
			}
		});

		initBtnStates();

		btn_cancel.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				MyDialog.Builder dialog = new MyDialog.Builder(JclqHhtz.this);
				dialog.setTitle("退出提示");
				dialog.setMessage("退出后您的选项将不会保存，确认继续?");
				dialog.setPositiveButton("确定", new DialogInterface.OnClickListener() {
					@Override
					public void onClick(DialogInterface dialog, int which) {
						// 获得自定义的应用程序BallDTO,初始化
						Intent data = new Intent();
						childDTO.hhtz1 = "";
						childDTO.hhtz2 = "";
						childDTO.hhtz3 = "";
						childDTO.hhtz4 = "";
						childDTO.lqhhtzsp = "";
						data.putExtra("info", childDTO);
						data.putExtra("gindex", gInd);
						data.putExtra("cindex", cInd);
						setResult(RESULT_OK, data);
						JclqHhtz.this.finish();
					}
				});
				dialog.setNegativeButton("取消", new DialogInterface.OnClickListener() {
					@Override
					public void onClick(DialogInterface dialog, int which) {
						dialog.cancel();
					}
				}).create().show();
			}
		});

		btn_ok.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View arg0) {
				// TODO Auto-generated method stub
				String sp = "";
				if (btn_sf_zs.isSelected() == true) {
					sp += ("sf," + btn_sf_zs.getTag().toString() + "/");// 1
				}
				if (btn_sf_zf.isSelected() == true) {
					sp += ("sf," + btn_sf_zf.getTag().toString() + "/");
				}
				if (btn_rfsf_zs.isSelected() == true) {
					sp += ("rf," + btn_rfsf_zs.getTag().toString() + "/");
				}
				if (btn_rfsf_zf.isSelected() == true) {
					sp += ("rf," + btn_rfsf_zf.getTag().toString() + "/");
				}
				if (btn_dxf_df.isSelected() == true) {
					sp += ("dxf," + btn_dxf_df.getTag().toString() + "/");
				}
				if (btn_dxf_xf.isSelected() == true) {
					sp += ("dxf," + btn_dxf_xf.getTag().toString() + "/");
				}
				if (btn_sfc_zs1.isSelected() == true) {
					sp += ("sc," + btn_sfc_zs1.getTag().toString() + "/");
				}
				if (btn_sfc_zs2.isSelected() == true) {
					sp += ("sc," + btn_sfc_zs2.getTag().toString() + "/");
				}
				if (btn_sfc_zs3.isSelected() == true) {
					sp += ("sc," + btn_sfc_zs3.getTag().toString() + "/");
				}
				if (btn_sfc_zs4.isSelected() == true) {
					sp += ("sc," + btn_sfc_zs4.getTag().toString() + "/");
				}
				if (btn_sfc_zs5.isSelected() == true) {
					sp += ("sc," + btn_sfc_zs5.getTag().toString() + "/");
				}
				if (btn_sfc_zs6.isSelected() == true) {
					sp += ("sc," + btn_sfc_zs6.getTag().toString() + "/");
				}
				if (btn_sfc_ks1.isSelected() == true) {
					sp += ("sc," + btn_sfc_ks1.getTag().toString() + "/");
				}
				if (btn_sfc_ks2.isSelected() == true) {
					sp += ("sc," + btn_sfc_ks2.getTag().toString() + "/");
				}
				if (btn_sfc_ks3.isSelected() == true) {
					sp += ("sc," + btn_sfc_ks3.getTag().toString() + "/");
				}
				if (btn_sfc_ks4.isSelected() == true) {
					sp += ("sc," + btn_sfc_ks4.getTag().toString() + "/");
				}
				if (btn_sfc_ks5.isSelected() == true) {
					sp += ("sc," + btn_sfc_ks5.getTag().toString() + "/");
				}
				if (btn_sfc_ks6.isSelected() == true) {
					sp += ("sc," + btn_sfc_ks6.getTag().toString() + "/");
				}
				childDTO.lqhhtzsp = sp;

				// Log.v("JclqHhtz",
				// "btn_ok.setOnClickListener sp= "+sp.toString());
				// Log.v("JclqHhtz",
				// "btn_ok.setOnClickListener childDTO.hhtz1= "+childDTO.hhtz1.toString());
				// Log.v("JclqHhtz",
				// "btn_ok.setOnClickListener childDTO.hhtz2= "+childDTO.hhtz2.toString());
				// Log.v("JclqHhtz",
				// "btn_ok.setOnClickListener childDTO.hhtz3= "+childDTO.hhtz3.toString());
				// Log.v("JclqHhtz",
				// "btn_ok.setOnClickListener childDTO.hhtz4= "+childDTO.hhtz4.toString());
				// Log.d("JclqHhtz",
				// "btn_ok.setOnClickListener childDTO.getHhtz1()= "+childDTO.getHhtz1().toString());
				// Log.v("JclqHhtz",
				// "btn_ok.setOnClickListener childDTO.mId= "+childDTO.mId.toString());

				Intent data = new Intent();
				data.putExtra("info", childDTO);
				data.putExtra("gindex", gInd);
				data.putExtra("cindex", cInd);
				setResult(RESULT_OK, data);
				JclqHhtz.this.finish();
			}
		});

	}

	public void onResume() {
		super.onResume();
		
	}

	public void onPause() {
		super.onPause();
		
	}

	public void initBtnStates() {
		if (!TextUtils.isEmpty(childDTO.hhtz1)) {
			if (childDTO.hhtz1.contains("2")) {
				btn_sf_zf.setSelected(true);
			} else {
				btn_sf_zf.setSelected(false);
			}
			if (childDTO.hhtz1.contains("1")) {
				btn_sf_zs.setSelected(true);
			} else {
				btn_sf_zs.setSelected(false);
			}
		}
		if (!TextUtils.isEmpty(childDTO.hhtz2)) {
			if (childDTO.hhtz2.contains("2"))
				btn_rfsf_zf.setSelected(true);
			else
				btn_rfsf_zf.setSelected(false);
			if (childDTO.hhtz2.contains("1"))
				btn_rfsf_zs.setSelected(true);
			else
				btn_rfsf_zs.setSelected(false);
		}
		if (!TextUtils.isEmpty(childDTO.hhtz3)) {
			if (childDTO.hhtz3.contains("2"))
				btn_dxf_xf.setSelected(true);
			else
				btn_dxf_xf.setSelected(false);

			if (childDTO.hhtz3.contains("1"))
				btn_dxf_df.setSelected(true);
			else
				btn_dxf_df.setSelected(false);
		}
		if (!TextUtils.isEmpty(childDTO.hhtz4)) {
			if (childDTO.hhtz4.contains("1"))
				btn_sfc_ks1.setSelected(true);
			else
				btn_sfc_ks1.setSelected(false);

			if (childDTO.hhtz4.contains("2"))
				btn_sfc_ks2.setSelected(true);
			else
				btn_sfc_ks2.setSelected(false);

			if (childDTO.hhtz4.contains("3"))
				btn_sfc_ks3.setSelected(true);
			else
				btn_sfc_ks3.setSelected(false);

			if (childDTO.hhtz4.contains("4"))
				btn_sfc_ks4.setSelected(true);
			else
				btn_sfc_ks4.setSelected(false);

			if (childDTO.hhtz4.contains("5"))
				btn_sfc_ks5.setSelected(true);
			else
				btn_sfc_ks5.setSelected(false);

			if (childDTO.hhtz4.contains("6"))
				btn_sfc_ks6.setSelected(true);
			else
				btn_sfc_ks6.setSelected(false);

			if (childDTO.hhtz4.contains("a"))
				btn_sfc_zs1.setSelected(true);
			else
				btn_sfc_zs1.setSelected(false);

			if (childDTO.hhtz4.contains("b"))
				btn_sfc_zs2.setSelected(true);
			else
				btn_sfc_zs2.setSelected(false);

			if (childDTO.hhtz4.contains("c"))
				btn_sfc_zs3.setSelected(true);
			else
				btn_sfc_zs3.setSelected(false);

			if (childDTO.hhtz4.contains("d"))
				btn_sfc_zs4.setSelected(true);
			else
				btn_sfc_zs4.setSelected(false);

			if (childDTO.hhtz4.contains("e"))
				btn_sfc_zs5.setSelected(true);
			else
				btn_sfc_zs5.setSelected(false);

			if (childDTO.hhtz4.contains("f"))
				btn_sfc_zs6.setSelected(true);
			else
				btn_sfc_zs6.setSelected(false);
		}

	}

	@Override
	public void finish() {
		// TODO Auto-generated method stub
		super.finish();
	};

	public boolean onKeyDown(int keyCode, KeyEvent event) {
		if (keyCode == KeyEvent.KEYCODE_BACK) {
			MyDialog.Builder dialog = new MyDialog.Builder(JclqHhtz.this);
			dialog.setTitle("退出提示");
			dialog.setMessage("退出后您的选项将不会保存，确认继续?");
			dialog.setPositiveButton("确定", new DialogInterface.OnClickListener() {
				@Override
				public void onClick(DialogInterface dialog, int which) {
					// 获得自定义的应用程序BallDTO,初始化
					Intent data = new Intent();
					childDTO.hhtz1 = "";
					childDTO.hhtz2 = "";
					childDTO.hhtz3 = "";
					childDTO.hhtz4 = "";
					childDTO.lqhhtzsp = "";
					data.putExtra("info", childDTO);
					data.putExtra("gindex", gInd);
					data.putExtra("cindex", cInd);
					setResult(RESULT_OK, data);
					JclqHhtz.this.finish();
				}
			});
			dialog.setNegativeButton("取消", new DialogInterface.OnClickListener() {
				@Override
				public void onClick(DialogInterface dialog, int which) {
					dialog.cancel();
				}
			}).create().show();
		} else {
			return super.onKeyDown(keyCode, event);
		}
		return true;
	}
}
